#pragma once

#include <iostream>
#include <queue>
#include <memory>
#include "Connection.hpp"
#include "./module/mutex.hpp"
using namespace MutexModule;

class ConnectionPool
{
public:
    ConnectionPool(){}
    ~ConnectionPool(){}
    void emplace(int sockfd)
    {
        mutexguard lock(_mutex);
        _connection_pool.emplace(sockfd);
    }
    int get()
    {
        mutexguard lock(_mutex);
        int conn = _connection_pool.front();
        _connection_pool.pop();
        return conn;
    }
private:
    std::queue<int> _connection_pool;
    Mutex _mutex;
};